<?php

die("Thankyou for your interest in our project but please do not try and access the old files as it jsut fills the errors panel up with errors which are meaninless, this page will be upgraded later but for now please make do without it.");

/**
 * CreateBanner.php
 *
 * @version 1.0
 * @copyright 2008 By e-Zobar for XNova
 */

define('INSIDE'  , true);
define('INSTALL' , false);

define('ROOT_PATH' , '');
include(ROOT_PATH . 'common.php');

includeLang('overview');

// Function to center text in the created banner
function CenterTextBanner($z,$y,$zone) {
	$a = strlen($z);
	$b = imagefontwidth($y);
	$c = $a*$b;
	$d = $zone-$c;
	$e = $d/2;
	return $e;
}

extract($_GET);
if (isset($id)) {
	// Querys
	$Player = doquery("SELECT * FROM {{table}} WHERE `id` = '".$id."';", 'users', true);
	$Stats  = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '".$id."';", 'statpoints', true);
	$Planet = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '".$id."' AND `planet_type` = '1' LIMIT 1;", 'planets', true);
	
	// Parameters
	header ("Content-type: image/png");
	$image  = imagecreatefrompng($Player['banner_source_post']);
	$date   = date("d/m/y");
	
	//What do we show? (MadnessRed)
	if($user['banner_display'] == 1){
		$opt = "rank";
	}elseif($user['banner_display'] == 2){
		$opt = "count";
	}else{
		$opt = "points";
	}

	// Variables
	$b_univ   = $game_config['game_name'];
	$b_user   = $Player['username'];
	$b_planet = $Planet['name'];
	$b_xyz    = "[".$Planet['galaxy'].":".$Planet['system'].":".$Planet['planet']."]";
	$b_lvl    = "".$Stats['total_rank']."/".$game_config['users_amount']."";
	$b_build  = "".$lang['ov_pts_build'] .": ".pretty_number($Stats['build_'.$opt])."";
	$b_fleet  = "".$lang['ov_pts_fleet'] .": ".pretty_number($Stats['fleet_'.$opt] + $Stats['def_'.$opt])."";
	$b_search = "".$lang['ov_pts_reche'] .": ".pretty_number($Stats['tech_'.$opt])."";
	$b_total  = "".$lang['ov_pts_total'] .": ".pretty_number($Stats['total_'.$opt])."";


	// Colors
	$color  = "FFFFFF";
	$red    = hexdec(substr($color,0,2));
	$green  = hexdec(substr($color,2,4));
	$blue   = hexdec(substr($color,4,6));
	$select = imagecolorallocate($image,$red,$green,$blue);

	// Display
	// Univers name
	imagestring($image, 1, CenterTextBanner($b_univ,1,653), 57, $b_univ, $select);
	// Today date
	imagestring($image, 1, CenterTextBanner($date,1,653), 65, $date, $select);
	// Player name
	imagestring($image, 3, 15, 12, $b_user, $select);
	// Player b_planet
	imagestring($image, 3, 150, 12, "".$b_planet." ".$b_xyz."", $select);
	// Player level
	imagestring($image, 10, CenterTextBanner($b_lvl,10,795), 40, $b_lvl, $select);
	// Player stats
	imagestring($image, 2, 15,  38, $b_build,  $select);
	imagestring($image, 2, 15,  55, $b_fleet,  $select);
	imagestring($image, 2, 150, 38, $b_search, $select);
	imagestring($image, 2, 150, 55, $b_total,  $select);

	// Creat and delete banner
	imagepng ($image);
	imagedestroy ($image);
}

?>
